#ifndef YANGEDIT_H
#define YANGEDIT_H

#include <QFileDialog>
#include <QFile>
#include <QTextStream>
#include <QMessageBox>
#include <QList>
#include <QSettings>
#include <QFileInfo>
#include <Qsci/qsciscintilla.h>
#include <QIcon>
#include <QDesktopWidget>
#include <QPoint>
#include<QSettings>
#include<QProcess>
#include<Qsci/qsciapis.h>
//##################################
#include "ui_YangEdit.h"
#include "TabWidget.h"	
#include "Config.h"
#include "Pref.h"
#include "LexerUtil.h"
#include "FindDirDialog.h"
#include "ReplaceTextDialog.h"
#include "FindText.h"
#include "GoToLine.h"
#include "Scintilla.h"
#include "ds/tree.h"
#include "MacrosManger.h"
#include "RclXml.h"
#include "ChooseFile.h"
#include "OptionDialog.h"
//#include "parser/BisonPublic.h"
//##################################
//ctags -R --fields=+aiKSzn
class YangEdit:public QMainWindow
{
	Q_OBJECT
	public:
		YangEdit(QWidget* parent = 0);	
		~YangEdit();
		//inline QsciScintilla* getCurDoc()
		inline Scintilla* getCurDoc()
		{
			return TextEdit;
		}
		Ui::YangEdit ui;
	protected:
            void closeEvent(QCloseEvent *event);
            virtual bool event(QEvent *event);
	private:
		void CreateActions(void);
		bool SaveFile(const QString& FileName);
		void getCurrentFile(void);
		bool MayBeSave();
		QString StrippedName(const QString &fullFileName);
		void GetCurTextEdit(void);
		void CreateTabPage(void);
		void GetRecentOpenFile(void);
		void AddRecentOpenFile(const QString& FileName);
		inline void DealAction(const QString& FileName);
		inline void SetFoldStyle();
		void CommentC();
		void UnCommentC();
		void CommentLineC();
		void BlockStreamC();
		void ReadFileToTree(const QString& dir,tree* ATree);
		void CreateProjectFile();
        //void CtagsFiles(const QString& ctags,const QString& dir);
		//QsciScintilla* TextEdit;
		Scintilla* TextEdit;
		QWidget* CurrTab;
		QString CurFileName;
		TabWidget* FileTab;
		FindDir* FindDirDialog;
		dlgFindText* FindText;
		ReplaceTextDialog* ReplaceText;
        Option* OptionDialog;
		GoToLine* GoToLineDialog;
		ChooseFile* ChooseFileDialog;
		QList<QFileInfo> RecentFileList;
		QMenu* RecentMenu;
		bool isFullScreenFull;
		bool isFoldAll;
		bool isCollapse;
		tree* FileTree;
		QLabel* LineIndex;
		MacrosManger* MM;
        QString ConfPath;
        rclxml* ProConfig;
        QString CurrProjectName;    //目前只能管理一个项目，项目名就是项目目录名
	private slots:
		void NewFile();
        void Open();
        bool Save();
        bool SaveAs();
        void About();
		void Undo();
		void Redo();
		void Copy();
		void Cut();
		void Paste();
		void RemoveSelectedText();
		void SelectAll();
    		void DocumentWasModified();
		void ChangeTab(int index);
		void LoadFile(QString fn);
		void LoadFile(QString FileName,int LineNum);
		void ShowFindTextDialog(void);
		void ShowGoToLineDialog(void);
		void ShowReplaceTextDialog(void);
		void OpenRecent(QAction* Action);
		void CodeFolding(void);
		void SetEolVisibility(bool val);
		void SetEolType(QAction* type);
		void SetHightLight(QAction* Type);
		void ZoomIn();
		void ZoomOut();
		void Wrap();
		void ShowFullScreen();
		void SetReadOnly();
		void FoldAll();
		void UnFoldAll();
		void UnCollapse();
		void Collapse();
		void GoToMacthingBrace();
		void InsertTab();
		void RemoveTab();
		void DumplicateLine();
		void MoveUpCurrentLine();
		void MoveDownCurrentLine();
		void SelectText();
		void ToUpper();
		void ToLower();
		void BlockToggleComment();
		void BlockComment();
		void BlockUnComment();
		void BlockStream();
		void StatusCursorPosition(int Line,int Index);
		void NewProject();
		void OpenProject();
		void ShowChooseFile();
		void OpenIncludeFile(const QString& FileName);
        void ShowOption();
        void AddFiles();
        void AddDirs();
        void CloseProject();
	 signals:
		void SendCloseAllTab(void);
};

#endif
